package com.moli.iov.admin.utils;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class ListUtil {
    public static <T> List copyProperties(List<T> origs, Class destElementTpe){
        if(destElementTpe==null){
            return null;
        }
        List list = new ArrayList<>();
        try{
            for (T orig: origs) {
                Object t =  destElementTpe.newInstance();
                list.add(t);
                BeanUtils.copyProperties(orig,t);
            }
            return list;
        }catch (Exception e){
            throw new RuntimeException(e.getMessage());
        }

    }
}
